package edu.univercidade.tcc.server.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

import edu.univercidade.tcc.server.validator.MembershipMustHaveRole;

@RooJavaBean
@RooToString
@RooEntity
@MembershipMustHaveRole
public class Membership {

    @NotNull
    @ManyToOne
    @JoinColumn(name = "member_id")
    private ProjectMember member;

    @NotNull
    @ManyToOne
    @JoinColumn(name = "project_id")
    private Project project;

    @ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
    private Set<ProjectRole> roles = new HashSet<ProjectRole>();

}
